﻿Imports System.Data
Imports VSModel
Imports Cls_Common
Imports SecurityService
Partial Class FrontEnd_Control_Contents_Detail
    Inherits System.Web.UI.UserControl
    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            If Page.RouteData.Values("Id") <> "" Then
                hidId.Value = Page.RouteData.Values("Id")
                If hidId.Value = "" Then
                    hidId.Value = 0
                End If
            End If
            BindMenu()
        End If
    End Sub
    Protected Sub BindMenu()
        Using data As New VSEntities
            'ParenId = 0 Menu cha
            'MenuPosition = 1 hien thi tren menu
            Dim d = (From p In data.Contents Where p.Id = hidId.Value Select p).FirstOrDefault
            ltrTitle.Text = d.Title
            'neu la video IsYoutube = true se hien thi video
            Dim _video = (From p In data.Contents Where (p.Id = hidId.Value And p.IsYoutube = True) Select p).FirstOrDefault
            If Not _video Is Nothing Then
                ltrZoomImgDetail1.Text = "<a id='ZoomImgDetail' class='badge-post-zoom zoomable' style='min-height:600px;" & "Display:none;" & "' href='javascript: void(0);'>"
                ltrVideo.Text = _video.URL
                ltrZoomImgDetail2.Text = "</a>"
            Else
                ltrZoomImgDetail1.Text = "<a id='ZoomImgDetail' class='badge-post-zoom zoomable' style='min-height:600px;' href='javascript: void(0);'>"
                imgDetail.ImageUrl = CookedImageURL("600-450", d.Image)
                ltrZoomImgDetail2.Text = "</a>"
            End If
            lplNameReport.NavigateUrl = MainDomain & "u/" & d.Author & ".html"
            lplNameReport.Text = d.Author

            lplLinkReport.NavigateUrl = "javascript: void(0);"
            lplLinkReport.CssClass = "badge-item-report"
            lplLinkReport.Text = "Report"
            lplLinkReport.Target = "_blank"
        End Using
    End Sub
End Class
